// https://zhuanlan.zhihu.com/p/3604866493
// import { RuntimeGlobals, RuntimeModule, runtime } from "webpack";
import { Container, inject, injectable } from "inversify";

interface Weapon {
  damage: number;
}

@injectable()
class Katana implements Weapon {
  readonly damage: number = 10;
}

// @Bind(weaponServiceId)
// const __container__: Container = new Container();
// export __container__.bind(weaponServiceId).to(Katana);
// static Define
const weaponServiceId: symbol = Symbol.for("WeaponServiceId");
@injectable()
class Ninja {
  constructor(
    @inject(weaponServiceId)
    readonly weapon: Weapon,
  ) {}
}
/// //////////////
// client code //
/// //////////////

// runtime code
const container: Container = new Container();

// register
void container.bind(Ninja).toSelf();
void container.bind(weaponServiceId).to(Katana);

// get instance
const ninja: Ninja = container.get(Ninja);

console.log(ninja.weapon.damage);
